<script setup>

// 定义组件接收的 props
const props = defineProps({
  message: {
    type: String,
    default: '默认消息'
  },
  user: {
    type: Object,
    required: true
  },
  items: {
    type: Array,
    default: () => []
  }
});
</script>

<template>
  <div class="parent-to-child">
    <div class="prop-section">
      <h4>字符串 Prop</h4>
      <p class="prop-value">{{ message }}</p>
    </div>
    
    <div class="prop-section">
      <h4>对象 Prop</h4>
      <div class="prop-value">
        <p>姓名: {{ user.name }}</p>
        <p>年龄: {{ user.age }}</p>
      </div>
    </div>
    
    <div class="prop-section">
      <h4>数组 Prop</h4>
      <ul class="prop-list">
        <li v-for="(item, index) in items" :key="index">
          {{ item }}
        </li>
      </ul>
    </div>
  </div>
</template>

<style scoped>
.parent-to-child {
  display: grid;
  gap: 1.5rem;
}

.prop-section {
  padding: 1rem;
  background: #f8f9fa;
  border-radius: 8px;
  border-left: 4px solid #667eea;
}

.prop-section h4 {
  margin-bottom: 0.5rem;
  color: #667eea;
  font-size: 1rem;
}

.prop-value {
  color: #333;
}

.prop-list {
  list-style: none;
  padding: 0;
}

.prop-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid #eee;
}

.prop-list li:last-child {
  border-bottom: none;
}
</style>